Skip to content

Fix HEC useACK unmarshal error on Splunk Cloud 8.2+#231

Open
raman1236 wants to merge 1 commit into
splunk:masterfrom
raman1236:fix/hec-useack-bool-unmarshal
Open

Fix HEC useACK unmarshal error on Splunk Cloud 8.2+#231
raman1236 wants to merge 1 commit into
splunk:masterfrom
raman1236:fix/hec-useack-bool-unmarshal

Conversation

@raman1236

Copy link
Copy Markdown

Description

Fixes #130

On Splunk Cloud 8.2+ (Victoria Experience), the HTTP Event Collector API returns "true"/"false" as string values for the useACK field, instead of the numeric "0"/"1" returned by earlier versions. This causes the JSON decoder to fail with:

json: invalid use of ,string struct tag, trying to unmarshal "true" into int

Changes

  • Introduced a custom IntBool type in client/models/http_event_collector.go that implements json.Unmarshaler
  • The custom type handles both numeric strings ("0"/"1") and boolean strings ("true"/"false")
  • Updated HttpEventCollectorObject.UseACK field from int to IntBool
  • Updated the resource code to cast IntBool to int when interacting with the Terraform schema

Impact

This is a backward-compatible fix. The use_ack attribute in the Terraform schema remains TypeInt (0 or 1). The custom type transparently handles both response formats from different Splunk versions.

Splunk Cloud 8.2+ returns "true"/"false" as string values for the
useACK field in HTTP Event Collector responses, instead of "0"/"1".
The previous json:",string" struct tag expected a numeric string and
failed with: json: invalid use of ,string struct tag, trying to unmarshal
"true" into int

Fix: Replace the int type with a custom IntBool type that implements
json.Unmarshaler to handle both numeric ("0"/"1") and boolean
("true"/"false") string representations.

Fixes splunk#130
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

splunk_inputs_http_event_collector throws error trying to unmarshal "true" into int

2 participants